using System.Collections.Generic;
using Data.Interface;
using Map;
using MoonFramework;
using MoonFramework.Scripts.Pool;
using UnityEngine;

namespace Data
{
    public struct MapInitData
    {
        public int mapSize;
        public int mapSeed;
        public int spawnSeed;
        public float marshLimit;

        public MapInitData(MapInitDataPro mapInitDataPro)
        {
            this.mapSize = mapInitDataPro.MapSize;
            this.mapSeed = mapInitDataPro.MapSeed;
            this.spawnSeed = mapInitDataPro.SpawnSeed;
            this.marshLimit = mapInitDataPro.MarshLimit;
        }
    }

    /// <summary>
    /// 地图块数据
    /// </summary>
    public class MapBlockData
    {
        public Dictionary<ulong, MapObjectData> MapBlockMapObjects;
        public Dictionary<ulong, MapObjectData> MapBlockAIObjects;

        public List<MapVertex> ForestMapVertices;
        public List<MapVertex> MarshMapVertices;
    }

    /// <summary>
    /// 地图块上对象数据
    /// </summary>
    public class MapObjectData
    {
        //唯一的身份标识
        public ulong ID;
        public int configID;
        public int DestroyDays;
        public Vector3 position;

        public void Init(ulong id, int configID, int destroyDays, Vector3 position)
        {
            ID = id;
            this.configID = configID;
            this.position = position;
            DestroyDays = destroyDays;
        }

        public static MapObjectData CreateMapObjectData(ulong id, int configID, int destroyDays, Vector3 position)
        {
            return ObjPoolManager.Instance.Pop(() => new MapObjectData(),
                res => { res.Init(id, configID, destroyDays, position); });
        }
    }
    
    /// <summary>
    /// 上个存档中存在的地图块
    /// </summary>
    public class MapData
    {
        public ulong CurID = 1;     //当前地图对象ID取值
        public List<Vector2Int> MapBlocks;
        public Dictionary<ulong, IMapObjectTypeData> MapObjectTypeData;
    }
}